/* ---------------------------------------------------------------------------------------------
 *
 *            Capital Alliance Software Confidential Proprietary
 *            (c) Copyright CAS 201{x}, All Rights Reserved
 *                          www.pekall.com
 *
 * ----------------------------------------------------------------------------------------------
 */

package com.pekall.myDictionary.screens;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.View;

public class PronunciationView extends View {
    private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    private Typeface mFace;

    private String mText;

    public PronunciationView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PronunciationView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mFace = Typeface.createFromAsset(getContext().getAssets(), "pron.ttf");
        mPaint.setTextSize(20);
    }

    public void setText(String text) {
        mText = text;
    }

    public void onDraw(Canvas canvas) {
        canvas.drawColor(Color.BLACK);

        if (mText != null) {
            mPaint.setTypeface(mFace);
            mPaint.setColor(Color.WHITE);
            canvas.drawText(mText, 0, 20, mPaint);
        }
    }

    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int widthSize = MeasureSpec.getSize(widthMeasureSpec);
        setMeasuredDimension(widthSize, 25);
    }

}
